﻿@page
@{ Layout = "_Layout"; }

<el-card class="box-card">
    <el-form v-on:submit.native.prevent :inline="true" :size="euiSize">
        <el-form-item label="商品">
            <el-input v-model="form.keyWords"
                      prefix-icon="el-icon-search" clearable
                      placeholder="关键字" v-on:input="btnSearch">
            </el-input>
        </el-form-item>
        <el-form-item label="">
            <el-button icon="el-icon-search" type="primary" :size="euiSize" v-on:click="btnSearch">查 询</el-button>
        </el-form-item>
        <el-form-item label="">
            <el-button :size="euiSize" plain type="primary" icon="el-icon-plus" v-on:click="btnEditClick(0)">
                新增商品
            </el-button>
        </el-form-item>
    </el-form>

    <el-table :data="list" style="width: 100%;" :size="euiSize"
              :height="($(window).height() - 163)">
        <el-table-column label="#" :default-sort="{prop: 'createdDate', order: 'descending'}"
                         type="index"
                         width="60"
                         align="left">
            <template scope="scope">
                <span>{{ scope.$index + 1 }}</span>
            </template>
        </el-table-column>
        <el-table-column width="130">
            <template slot-scope="scope">
                <el-image style="width: 100px; height: 60px"
                          :src="scope.row.coverImg[0]" :preview-src-list="scope.row.coverImg"
                          fit="cover"></el-image>
            </template>
        </el-table-column>
        <el-table-column label="名称" prop="name"></el-table-column>
        <el-table-column label="积分" prop="point" width="80"></el-table-column>
        <el-table-column prop="locked" label="状态" width="80">
            <template slot-scope="scope">
                <span v-if="scope.row.locked"><el-tag size="mini" type="danger" effect="dark">已停用</el-tag></span>
                <span v-else><el-tag size="mini" type="success" effect="dark">启用</el-tag></span>
            </template>
        </el-table-column>
        <el-table-column width="88" label="兑换人数" prop="shopTotal">
            <template slot-scope="scope">
                <el-link type="primary" v-on:click.native="btnListClick(scope.row)" v-if="scope.row.shopTotal>0">{{ scope.row.shopTotal }}</el-link>
                <span v-else>0</span>
            </template>
        </el-table-column>
        <el-table-column width="150" sortable
                         prop="createdDate"
                         label="创建时间">
        </el-table-column>
        <el-table-column label="创建人" width="100" show-overflow-tooltip>
            <template slot-scope="scope">
                <el-link :underline="false" type="primary" v-on:click="utils.openAdminView(scope.row.creatorId)" v-if="scope.row.creatorId>0">{{scope.row.creator}}</el-link>
                <el-tag v-else size="mini" type="danger" effect="dark">{{scope.row.creator}}</el-tag>
            </template>
        </el-table-column>
        <el-table-column label="" align="right" width="100">
            <template slot-scope="scope">
                <el-dropdown :show-timeout="0" placement="left">
                    <el-button icon="el-icon-arrow-left" size="mini" v-on:click.stop="return false">
                        操作
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item icon="el-icon-edit" v-on:click.native="btnEditClick(scope.row.id)">编辑</el-dropdown-item>
                        <el-dropdown-item icon="el-icon-user" v-on:click.native="btnRangeClick(scope.row.id)" v-if="scope.row.groupType==='Fixed'">安排用户</el-dropdown-item>
                        <el-dropdown-item icon="el-icon-delete" style="color:red;" v-on:click.native="btnDeleteClick(scope.row)" divided>删除</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </template>
        </el-table-column>
        @await Html.PartialAsync("_PartialTableEmpty")
    </el-table>
    <div style="text-align: center; margin-top: 13px;">
        <el-pagination v-on:current-change="handleCurrentChange" background
                       :current-page="form.pageIndex"
                       :page-size="form.pageSize"
                       layout="total, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
    </div>
</el-card>
@section Scripts{
    <script src="/sitefiles/assets/js/admin/points/gifts.js" type="text/javascript"></script>
}